import { getHomeHotSuggests,getHomeCategories,getHomeHouselist } from '@/service';
import {defineStore} from 'pinia'

const homeStore=defineStore('homeStore',{
    state:()=>({
        hotSuggests: [],
        categories: [],
        houselist: [],
        currentPage: 1,
    }),
    actions:{
        async getSuggests(){
            const res=await getHomeHotSuggests()
            this.hotSuggests=res.data
        },
        async fetchCategoriesData() {
            const res = await getHomeCategories()
            this.categories = res.data
          },
          async fetchHouselistData() {
            const res = await getHomeHouselist(this.currentPage)
            this.houselist.push(...res.data)
            this.currentPage++
          }
    }
})

export default homeStore